package cn.tedu.account.service;

import cn.tedu.account.mapper.AccountMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;

/**
 * @ClassName AccountServiceImpl
 * @Description:类描述
 * @Author Tedu
 * @Date 2021/7/1 10:29
 * @Version V1.0
 **/
@Service
public class AccountServiceImpl implements AccountService{
    @Autowired
    private AccountMapper accountMapper;
    @Transactional
    @Override
    public void decrease(Long userId, BigDecimal money) {
        accountMapper.decrease(userId, money);
        if (Math.random()<0.10){
            throw new RuntimeException("模拟扣减账户金额失败");
        }

    }
}
